﻿using FlexFlow.Base.Interface;
using FlexFlow.Model;
using MongoDB.Driver;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FlexFlow.DataProvider.MongoDB
{
    /// <summary>
    /// 表示流程步骤提供器的MongoDb实现
    /// </summary>
    public class MongoDbFlowSetpProvider : MongoDBPhysicalModelProvider<FlowSetp>, IFlowSetpProvider
    {
        /// <summary>
        /// 创建一个新的步骤
        /// </summary>
        /// <returns>
        /// 创建的步骤
        /// </returns>
        public override FlowSetp Create()
        {
            return new FlowSetp()
            {
                FlowTime = DateTime.Now
            };
        }
        /// <summary>
        /// 取得指定流程实例的流转步骤列表
        /// </summary>
        /// <param name="procInsId">
        /// 流程实例ID
        /// </param>
        /// <returns>
        /// 取得的流转步骤列表
        /// </returns>
        public List<FlowSetp> GetProcessInstanceSetps(Guid procInsId)
        {
            var col = GetCollection();
            FilterDefinition<FlowSetp> filter = (FilterDefinition<FlowSetp>)(m => m.ProcessInstanceId == procInsId);
            return col.GetAll(filter);
        }
    }
}
